import csv
import re


def process_text(input_file, output_file):
    with open(input_file, 'r', encoding='utf-8') as f:
        lines = f.readlines()

    data = []
    for line in lines:
        line = line.strip()

        # 定义正则表达式匹配各部分
        chinese_pattern = r'[\u4e00-\u9fa5]+'
        uppercase_english_pattern = r'\b[A-Z]{2,}\b'
        mixedcase_english_pattern = r'\b[A-Za-z][a-z]*\b'

        chinese_match = re.search(chinese_pattern, line)
        uppercase_english_match = re.search(uppercase_english_pattern, line)
        mixedcase_english_match = re.search(mixedcase_english_pattern, line)

        chinese = chinese_match.group(0) if chinese_match else ''
        uppercase_english = uppercase_english_match.group(0) if uppercase_english_match else ''
        mixedcase_english = ''

        if mixedcase_english_match:
            mixedcase_english = ' '.join(re.findall(mixedcase_english_pattern, line))

        data.append([chinese, uppercase_english, mixedcase_english])
        print("OK!")

    # 将数据写入CSV文件
    with open(output_file, 'w', newline='', encoding='utf-8') as csv_file:
        writer = csv.writer(csv_file)
        writer.writerow(['中文', '全大写英文', '大写加小写英文'])
        writer.writerows(data)


# 示例用法
process_text('input.txt', 'output1.csv')
